﻿Namespace Control
    Public Class Municipio
        Implements IControl(Of Model.Municipio)
        Implements IDisposable


        Public Function Excluir(ByVal entity As Model.Municipio) As Boolean Implements IControl(Of Model.Municipio).Excluir
            entity.Delete()
        End Function

        Public Function ListaTudo() As System.Collections.Generic.IList(Of Model.Municipio) Implements IControl(Of Model.Municipio).ListaTudo
            Return Model.Municipio.FindAll()
        End Function

        Public Function ListaUm(ByVal entity As Model.Municipio) As Model.Municipio Implements IControl(Of Model.Municipio).ListaUm
            Return Model.Municipio.Find(entity.cd_municipio)
        End Function

        Public Function GetByIBGE(ByVal ibge As Integer) As Model.Municipio
            Dim m As New Model.Municipio

            Return m.GetByIBGE(ibge)
        End Function

        Public Function GetByEstado(ByVal Estado As Model.Estado) As IList(Of Model.Municipio)
            Dim m As New Model.Municipio

            Return m.GetByEstado(Estado)
        End Function

        Public Function Salvar(ByVal entity As Model.Municipio) As Boolean Implements IControl(Of Model.Municipio).Salvar
            entity.Save()
        End Function

        Private disposedValue As Boolean = False        ' To detect redundant calls

        ' IDisposable
        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
            If Not Me.disposedValue Then
                If disposing Then
                    ' TODO: free other state (managed objects).
                End If

                ' TODO: free your own state (unmanaged objects).
                ' TODO: set large fields to null.
            End If
            Me.disposedValue = True
        End Sub

#Region " IDisposable Support "
        ' This code added by Visual Basic to correctly implement the disposable pattern.
        Public Sub Dispose() Implements IDisposable.Dispose
            ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
            Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub
#End Region

    End Class
End Namespace
